// store/messageStore.ts
import { defineStore } from 'pinia'

export const useMessageStore = defineStore('message', {
    state: () => ({
        unreadMap: {},
        messages: [],
        totalUnread: 0
    }),
    actions: {
        incrementUnread(senderId) {
            this.unreadMap[senderId] = (this.unreadMap[senderId] || 0) + 1;
        },
        setUnread(senderId,count){
            this.unreadMap[senderId] = count;
        },
        resetUnread(senderId) {
            this.unreadMap[senderId] = 0;
        },
        addMessage(message) {
            this.messages.push(message);
        }
    },
})